package cn.yuanqiao.archive.appManager.domain;

import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.core.domain.BaseEntity;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Map;

/**
 * @author zjj
 * @date 2023/6/15
 */
public class TenantYqda extends BaseEntity {

    private static final long serialVersionUID = 1L;

    public static final String BIGTABLENAME = "_YQDA";

    public TenantYqda() {
        if(SecurityUtils.getLoginUser() !=null){
            String tenantCode = SecurityUtils.getTenantCode();
            if(StringUtils.isEmpty(tenantCode)){
                if(SecurityUtils.getLoginUser() != null){
                    tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
                }
            /*if (StringUtils.isEmpty(tenantCode)){
                throw new ServiceException("TenantCode is null");
            }*/
            }
            this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
        }
    }

    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    @JsonFormat(shape = JsonFormat.Shape.STRING)//转化成string传到前端
    private Long daId;

    private Map<String, String> colNames;

    public Long getDaId() {
        return daId;
    }

    public void setDaId(Long daId) {
        this.daId = daId;
    }

    public Map<String, String> getColNames() {
        return colNames;
    }

    public void setColNames(Map<String, String> colNames) {
        this.colNames = colNames;
    }
}
